#include"pipe.hpp"

int main()
{
    bool b=creatpipe(NAMEPIPE);
    assert(b);
    (void)b;
    int rfd=open(NAMEPIPE,O_RDONLY);
    if(rfd<0) exit(-1);
    char buf[1024];
    while(true)
    {
        ssize_t s=read(rfd,buf,sizeof(buf)-1);
        if(s>0)
        {
            buf[s]=0;
            cout<<"client->serve# "<<buf<<endl;
        }
        else if(s==0)
        {
            cout<<"clent quit!"<<endl;
            break;
        }
        else
        {
            cout<<"err string:"<<strerror(errno)<<endl;
            break;
        }
    }
    close(rfd);
    remove(NAMEPIPE);
    return 0;
}